<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>

        document.write('5-10之间的数相加为:' + sum(5,10) + '<br>');
        document.write('100-1000之间的数相加为:' + sum(100,1000));

        function sum(n1 , n2){
            let ans = 0;
            for (let i = n1; i <= n2; i++){
                ans += i;
            }
            return ans;
        }

    </script>
</body>
</html>